import { Row, Col, Switch, Tag, DatePicker, Popover, Tooltip } from 'antd';
const MonthPicker = DatePicker.MonthPicker;
import objectAssign from 'object-assign'
import moment from 'moment';
import { WeaDateSwitch } from 'ecCom';

import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;


import { inject, observer } from 'mobx-react';
import { observable, action, toJS } from 'mobx';
@inject('meetingCalView')
@inject('meetingDialog')

@observer
export default class CalViewTab extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			date: new Date(),

		}
	}
	componentWillReceiveProps(nextProps) {
		if (moment(this.state.date).format("YYYY-MM-DD") != moment(nextProps.date).format("YYYY-MM-DD")) {
			this.setState({ date: nextProps.date });
		}
	}

	render() {
		let { status, changeType, getData, getCalendarList,isCalendar } = this.props.meetingCalView;
		let { type, meetingType, dataKey, meetingPerson } = toJS(status);
		let { date } = this.state;
		let curmoment = moment.isMoment(date) ? date : moment(date);
		// let dates = new Date();
		// let m = dates.getMonth()+1;
		let value = objectAssign({}, {
			selectUser: meetingPerson,
			selectdate: curmoment.format("YYYY-MM-DD"),
			meetingType: meetingType,//会议类型
		})
		return (
			<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@x4dwmc`} className="calviewtab" style={{ borderBottom: '1px solid #d9d9d9', display: 'block', height: '45px' }}>
				<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@dhrihn`} span="10" style={{ textAlign: "left", height: '45px' }}>
					{/* <WeaDateSwitch
                        style={{width:'220px',height:'46px',lineHeight:'46px',fontSize:'12px',marginLeft:'20px',color:'#333333',display:'inline-block'}}
                        defaultValue={new Date()}
                        onChange={this.changeMonth}
                        valueDate={this.state.date||new Date()}
                        /> */}
					<WeaDateSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaDateSwitch@upj6oa`} onChange={this.onChangeWeaDateSwitch} currentDay={date} currentType='month' typeList={[]} />
					<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@7ctdfe`} placement="bottom" title={getLabel(354,"刷新")} >
						<span className="icon-coms-Refresh" style={{
							cursor: 'pointer', padding: '0 10px', color: '#B2B2B2',
							fontSize: '16px', display: 'inline-block', position: 'absolute', top: '15px'
						}}
							onClick={() => {
								type == 1 || isCalendar?
									getData(value)
									:
									type == 2 || isCalendar ?
										getCalendarList(value)
										:
										''

							}

							}></span>
					</Tooltip>
				</Col>
				<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@bd4iza`} span="14" style={{ textAlign: "right", height: '45px' }}>
					<div style={{
						backgroundColor: type != 2||isCalendar ? '#00bafb' : '#ffffff', display: 'inline-block',
						cursor: 'pointer', height: '26px', width: '26px', marginTop: '8px', border: type != 2||isCalendar ? '1px solid #00bafb' : '1px solid #b2b2b2',
						borderTopLeftRadius: '2px', borderBottomLeftRadius: '2px'
					}}>
						<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@ilk5af`} className={'time-veiw'} arrowPointAtCenter={true} placement="bottomRight" title={getLabel(30885,"时间视图")} >
							<i className="icon-coms-Tile"
								style={{ color: type != 2||isCalendar ? '#ffffff' : '#bababa', fontSize: '14px', marginTop: '5px', marginRight: '5px', display: 'inline-block' }}
								onClick={() => { changeType(1) }}>
							</i>
						</Tooltip>
					</div>
					<div style={{
						backgroundColor: type == 2&&!isCalendar ? '#00bafb' : '#ffffff',
						marginRight: '15px', display: 'inline-block', cursor: 'pointer', height: '26px',
						width: '26px', marginTop: '8px', border: type == 2&&!isCalendar ? '1px solid #00bafb' : '1px solid #b2b2b2',
						borderTopRightRadius: '2px', borderBottomRightRadius: '2px'
					}}>
						<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@jba7dz`} className={'list-veiw'} arrowPointAtCenter={true} placement="bottomRight" title={getLabel(82532,"列表视图")}>
							<i className="icon-coms-List" style={{ color: type == 2 &&!isCalendar? '#ffffff' : '#bababa', fontSize: '14px', marginTop: '5px', marginRight: '5px', display: 'inline-block' }} 
							onClick={() => { changeType(2) }}>
							</i>
						</Tooltip>
					</div>
				</Col>
			</Row>

		)
	}
	/*时间组件切换回调 */
	onChangeWeaDateSwitch = (type, date, range) => {
		// type != this.state.timeType && this.setState({timeType: type},this.query)
		let dateClone = moment(date);//克隆date
		let stateDate = moment.isMoment(this.state.date) ? this.state.date : moment(this.state.date)
		dateClone.format("YYYY-MM-DD") != stateDate.format("YYYY-MM-DD") && this.props.meetingCalView.saveDate(dateClone.toDate())
	}

}


